package com.book.controller;

import com.book.model.dto.CampusQueryDTO;
import com.book.model.entity.Campus;
import com.book.service.CampusService;
import com.book.util.BaseResult;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 校区 前端控制器
 * </p>
 *
 * @author auto
 * @since 2025-04-03 10:23:06
 */
@RestController
@RequestMapping("/campus")
@Tag(name = "校区", description = "校区相关接口")
public class CampusController {

    @Autowired
    private CampusService campusService;

    @GetMapping("")
    @ApiOperation(value = "校区列表")
    public BaseResult<?> getCampusList() {
        return BaseResult.successResult(campusService.getCampusList());
    }

    @PostMapping("/getListByPage")
    @ApiOperation(value = "校区列表")
    public BaseResult<?> getCampusListByPage(@RequestBody CampusQueryDTO dto) {
        return BaseResult.successResult(campusService.getCampusListByPage(dto));
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加校区")
    public BaseResult<?> getCampusListByPage(@RequestBody Campus dto) {
        return BaseResult.successResult(campusService.addCampus(dto));
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除校区")
    public BaseResult<?> deleteCampus(@PathVariable("id") String id) {
        return BaseResult.successResult(campusService.removeById(id));
    }

}
